package com.sun.controller;

import com.sun.model.Stock;
import com.sun.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class StockController {

    @Autowired
    private StockService stockService;

    @GetMapping("/deduct")
    public String deduct() {
        stockService.deduct();
        return "OK";
    }

    @GetMapping("/deduct/all")
    public List<Stock> all() {
      return stockService.list();
    }
}
